BUILD_TIME := $(shell date +"%Y-%m-%d %H:%M:%S")
GIT_COMMIT := $(shell git show -s --pretty=format:%h)
GO_VERSION := $(shell go version)
BUILD_PATH := './build/bin/eth-monitor'

linux:
	@echo "start build service for linux..."
	GOOS=linux GOARCH=amd64 go build -v -ldflags "-w -s -X main.BuildNumber=${GIT_COMMIT} -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}'" -o $(BUILD_PATH)-linux-amd64  .
	chmod +x $(BUILD_PATH)-linux-amd64

macos:
	@echo "start build service for macos..."
	GOOS=darwin GOARCH=amd64 go build -v -ldflags "-w -s -X main.BuildNumber=${GIT_COMMIT} -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}'" -o $(BUILD_PATH)-darwin-amd64  .
	chmod +x $(BUILD_PATH)-darwin-amd64

win:
	@echo "start build service for windows..."
	GOOS=windows GOARCH=amd64 go build -v -ldflags "-w -s -X main.BuildNumber=${GIT_COMMIT} -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}'" -o $(BUILD_PATH)-windows-amd64.exe  .
	#chmod +x $(BUILD_PATH)-windows-amd64

all: macos linux win